/**
 * Created by 小虎Oni on 2016/9/29.
 * update on 2016/10/9
 */
var jquery = require('jquery');
var config = require('../config');
var server = config.server;
function xHttpPost(url,parms){
    var deferred = jquery.Deferred();
    url=server+url;
    jquery.ajax({
        url:url,
        type:'POST',
        data: parms,
        success: function (data) {
            if(data.code == "success"){
                deferred.resolve(data);
            }else{
                alert(data.code);
            }
        },
        error: function (error) {
            deferred.reject(error);
        }
    });
    return deferred.promise();
}
function xHttpGet(url,parms){
    var deferred = jquery.Deferred();
    url=server+url;
    jquery.ajax({
        url:url,
        type:'GET',
        data: parms,
        success: function (data) {
            deferred.resolve(data);
        },
        error: function (error) {
            deferred.reject(error);
        }
    });
    return deferred.promise();
}
function errorAction(error){


}
module.exports = {
    xHttpPost:xHttpPost,
    xHttpGet:xHttpGet
}
